#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

void Test1()
{
	int m = 3, n = 2;

	cin >> m >> n;
	vector<vector<int>> dp(m + 1);
	dp[0].resize(n + 1, 0);
	dp[0][1] = 1;
	for (int i = 1; i <= m; i++)
	{
		dp[i].resize(n + 1, 0);
		for (int j = 1; j <= n; j++)
		{
			dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
		}
	}

	cout << dp[m][n];

}

void Test2()
{
	int m = 3, n = 3;
	// vector<vector<int>> dp(m, vector<int>(n));
	vector<vector<int>> dp = { {1,3,1},{1,5,1},{4,2,1} };
	for (int i = 0; i < m; i++)
	{
		dp[i].resize(n + 1, 0);
	}
	dp.push_back(vector<int>(n + 1, 0));
	int i = 0, j = 0, sum = dp[0][0];
	while (i < m && j < n)
	{
		if (dp[i][j + 1] > dp[i + 1][j])
		{			sum += dp[i][j + 1];
			j++;
		}
		else
		{
			sum += dp[i + 1][j];
			i++;
		}
	}
	cout << sum;
}

void Test3(vector<vector<int>>& frist)
{
	// vector<vector<int>> dp(m + 1, vector<int>(n + 1));
	int m = frist.size();
	int n = frist[0].size();
	for (int i = 1; i < n; i++)
	{
		frist[0][i] += frist[0][i - 1];
	}
	for (int i = 1; i < m; i++)
	{
		frist[i][0] += frist[i - 1][0];
	}
	for (int i = 1; i < m; i++)
	{
		for (int j = 1; j < n; j++)
		{
			frist[i][j] += max(frist[i - 1][j], frist[i][j - 1]);
		}
	}
	cout << frist[m - 1][n - 1];
}

void Test4()
{

}

int main()
{

	//vector<vector<int>> v = { {1,2,5},{3,2,1} };
	//Test3(v);
	int n = 0;
	cin >> n;

	vector<long long> dp(n);

	dp[0] = 1; dp[1] = 2; dp[2] = 4;

	for (int i = 3; i < n; i++)
	{
		dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
	}

	cout << dp[n - 1];
	return 0;
}